package com.yf.exam.modules.trainingarchives.retrainingdescription.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.base.Preconditions;
import com.yf.exam.common.entity.Result;
import com.yf.exam.core.api.dto.BaseIdReqDTO;
import com.yf.exam.core.api.dto.PagingReqDTO;
import com.yf.exam.modules.trainingarchives.retrainingdescription.dto.req.OrgRetrainingDescriptionReqDTO;
import com.yf.exam.modules.trainingarchives.retrainingdescription.dto.resp.OrgRetrainingDescriptionRespDTO;
import com.yf.exam.modules.trainingarchives.retrainingdescription.service.OrgRetrainingDescriptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 复训说明表(OrgRetrainingDescription)表控制层
 *
 * @author gengjiaxuan
 * @since 2025-01-15 22:14:18
 */
@RestController
@RequestMapping("/orgRetrainingDescription")
@Slf4j
@Api(tags={"复训说明"})
public class OrgRetrainingDescriptionController {
    /**
     * 服务对象
     */
    @Resource
    private OrgRetrainingDescriptionService orgRetrainingDescriptionService;


    /**
     * 新增复训说明
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增复训说明")
    public Result<Boolean> add(@RequestBody OrgRetrainingDescriptionReqDTO reqDTO) {
        try {
            if (log.isInfoEnabled()) {
                log.info("OrgRetrainingDescriptionController.add.reqDTO:{}", JSON.toJSONString(reqDTO));
            }
            Preconditions.checkArgument(!StringUtils.isBlank(reqDTO.getWorkTypeId()), "工种类型不能为空!");
            Preconditions.checkNotNull(reqDTO.getRetrainingType(), "复训类型不能为空!");
            return Result.ok(orgRetrainingDescriptionService.add(reqDTO));
        } catch (Exception e) {
            log.error("OrgRetrainingDescriptionController.add.error:{}", e.getMessage(), e);
            return Result.faild("新增复训说明失败!");
        }
    }


}

